package com.kaiwukj.android.ufamily.mvp.model;

import com.alibaba.fastjson.JSON;
import com.kaiwukj.android.mcas.integration.IRepositoryManager;
import com.kaiwukj.android.mcas.mvp.BaseModel;
import com.kaiwukj.android.ufamily.mvp.http.api.service.SystemService;
import com.kaiwukj.android.ufamily.mvp.http.entity.params.OpinionParams;
import com.kaiwukj.android.ufamily.mvp.http.utils.RxUtils;
import com.kaiwukj.android.ufamily.mvp.ui.page.sys.SystemContract;

import javax.inject.Inject;

import io.reactivex.Observable;

public class SystemModel extends BaseModel implements SystemContract.Model {

    @Inject
    public SystemModel(IRepositoryManager repositoryManager) {
        super(repositoryManager);
    }

    @Override
    public Observable<Integer> postOpinion(String content, String phone) {
        OpinionParams params = new OpinionParams();
        params.setContent(content);
        params.setPhoneNo(phone);
        params.setFromType(1);
        params.setType(4);
        return mRepositoryManager.obtainRetrofitService(SystemService.class)
                .postOpinion(getRequestBody(JSON.toJSONString(params)))
                .compose(RxUtils.handleCode());
    }
}
